package com.zhou.gof.group.factory.factory;

import com.zhou.gof.group.factory.Animal;
import com.zhou.gof.group.factory.impl.Cat;
import com.zhou.gof.group.factory.impl.Dog;

/**
 * @author zhoudong
 * @title: AnimalFactory
 * @projectName user-app
 * @description: 工厂设计模式。以动物为例，区分猫和狗两种
 * @date 2019/5/29 13:17
 */
public class AnimalFactory {
    public static Animal getAnimal(String animalType){
        switch (animalType){
            case "cat":
                return new Cat();
            case "dog":
                return new Dog();
            default:
                System.out.println("类型错误");
                return new Dog();
        }
    }
}
